﻿@model iDMS.Models.Manufacturer
@using MvcHtmlHelpers
<script type="text/javascript">
    var geocoder;
    var map;
    function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var mapOptions = {
            zoom: 15,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.HYBRID
        }
        map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
        codeAddress();
    }

    function codeAddress() {
        var address = '@Model.Adress,@Model.City,@Model.PostCode,@Model.Country.Name';
        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location,
                    title: '@Model.Name'
                });
            } else {
                $('#map_canvas').hide();
            }
        });
    }

    function loadScript() {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "https://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize";
        document.body.appendChild(script);
    }

    window.onload = loadScript;
</script>
<script type="text/javascript">
    $(function () {
        $("#tabs").tabs({ spinner: 'Retrieving data... <img src="/Content/Images/spinner.gif"/>' });
    });
</script>
@{
    ViewBag.Title = "Details";
}
<h3>
    Manufacturer: @Model.Name - <span class="accent">Details</span></h3>
<div id="tabs">
    <ul>
        <li><a href="#tabs-1"><span>General Info</span></a></li>
        <li><a href="@Url.Action("ManufacturersDrawings", "Drawing", new { id = Model.ManufacturerID })">
            <span>Drawings</span></a> </li>
    </ul>
    <div id="tabs-1">
        <table style="width: auto">
            <tr>
                <td valign="top" style="width: 500px">
                    @Html.Partial("_Details", @Model)
                </td>
                <td valign="top">
                    <div id="map_canvas" style="height: 500px; width: 400px">
                        map</div>
                </td>
            </tr>
        </table>
    </div>
</div>
<p>
    @Html.ActionLink("Back to List", "Index", null, new { @class = "btl" })
    @Html.ActionLink("Edit", "Edit", new { id = Model.ManufacturerID }, new { @class = "editLink" })
    @Html.ActionLink("Delete", "Delete", new { id = Model.ManufacturerID }, new { @class = "deleteLink" })
</p>
